//
//  RoomInfoView.swift
//  GOFM
//
//  Created by siri on 2024/10/21.
//  Copyright © 2024 Glad. All rights reserved.
//

import SwiftUI

struct RoomInfoView: View {
       public var infoCode: Int
       @State private var isChoose = false
      
       var body: some View {
           VStack(spacing: 0) {
            
               HStack {
                   Text("A310北")
                   Text("(15人 tv 内网)").foregroundColor(Color(hex: "#b5b6b7")).font(.system(size: 15))
                   Toggle("", isOn: $isChoose)
                       .toggleStyle(CheckBoxToggleStyle(shape: .square))
                       .frame(alignment: .leading)
               }.frame(height: 50)
               Divider().frame(width: 100)
               
               Button(action: {
                   print("提交房间信息")
               }, label: {
                   Text("提交")
               }) .frame(width: 150,height: 40)
                   .foregroundColor(Color.g_color_font_white)
                   .background(Color.g_color_theme).offset(y: 300)
               Spacer()
           }.frame( height:600, alignment: .top)
       }
}

// 单选框
struct CheckBoxToggleStyle: ToggleStyle{
        enum CheckBoxShape: String{
            case circle
            case square
        }
        let shape : CheckBoxShape
        init(shape: CheckBoxShape = .circle){
            self.shape = shape
        }
        //configuration中包含isOn和label
        func makeBody(configuration: Configuration) -> some View {
            let systemName:String = configuration.isOn ? "checkmark.\(shape.rawValue).fill" : shape.rawValue
            Button(action: {
                configuration.isOn.toggle()
            }) {
                configuration.label
                Image(systemName: systemName)
                    .resizable()
                    .frame(width: 20, height: 20)
            }
        }
    }

struct RoomInfoView_Previews: PreviewProvider {
    static var previews: some View {
        RoomInfoView(infoCode: 1)
    }
}
